package com.codingvip.concurrent;

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.function.Function;

public class SkipMapDemo {

    public static void main(String[] args) {
        // Creating ConcurrentSkipListMap
        ConcurrentNavigableMap<String, Integer> cityTemperatureMap = new ConcurrentSkipListMap<>((o1, o2) -> {
            if (o1.equals(o2)) {
                return 0;
            }
            return o1.compareTo(o2) > 0 ? -1 : 1;
        });

        // Storing elements
        cityTemperatureMap.put("Delhi", 24);
        cityTemperatureMap.put("Mumbai", 32);
        cityTemperatureMap.put("Chennai", 35);
        cityTemperatureMap.put("Bangalore", 22 );
        cityTemperatureMap.put("Kolkata", 28);

        Set<Map.Entry<String, Integer>> cityTempSet = cityTemperatureMap.entrySet();
        cityTempSet.forEach((m)->System.out.println(m.getKey()+"--"+m.getValue()));

    }
}